package leetcode;

import java.util.ArrayList;
import java.util.List;

class Solution_78 {
    private List<List<Integer>> result = new ArrayList<>();

    private List<Integer> temp = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {
        backtracking(nums,0);
        return result;
    }

    private void backtracking(int[] nums,int start){
        if (start <= nums.length){
            result.add(new ArrayList<>(temp));
        }
        for (int i = start; i < nums.length; i++) {
            temp.add(nums[i]);
            backtracking(nums,i + 1);
            temp.removeLast();
        }
    }

    public static void main(String[] args) {

        List<List<Integer>> subsets = new Solution_78().subsets(new int[]{1, 2, 3});
        System.out.println(subsets);
    }
}